#include <stdio.h>

#define STATE(name) static void state_##name(void)
#define TRANSITION(from, to, event) [STATE_##from][EVENT_##event] = STATE_##to
//#undef TRANSITION

//#define TRANSITION(to) STATE_##to
#define TRANSITION(from, to, event) [EVENT_##event] = STATE_##to

#define BEGIN_STATES enum states {
#define END_STATES \
    STATE_COUNT \
    } \
    ;

#define BEGIN_EVENTS enum events {
#define END_EVENTS \
    EVENT_COUNT \
    } \
    ;

//STATE()

// 使用示例：
BEGIN_STATES
STATE_IDLE, STATE_RUNNING, STATE_ERROR,
    END_STATES

        BEGIN_EVENTS EVENT_START,
    EVENT_STOP, EVENT_ERROR,
    END_EVENTS

    //    static void (*state_table[STATE_COUNT][EVENT_COUNT])(void)
    //    = {[STATE_IDLE] = {RANSITION(IDLE, RUNNING, START)}

    //};
//c语言数组诡异的赋值语句
    static enum states state_table[STATE_COUNT][EVENT_COUNT]
    = {[STATE_IDLE] = {
           TRANSITION(IDLE, RUNNING, START)
//           STATE_RUNNING
       },
       [1][1]=0

};
int main()
{
    return 0;
}
